package com.example.gitpart03;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;

public class PingJiaAdapter extends RecyclerView.Adapter<PingJiaAdapter.ViewHolder> {

    private Context context;
    private List<PingJiaItem> pingJiaList;

    public PingJiaAdapter(Context context, List<PingJiaItem> pingJiaList) {
        this.context = context;
        this.pingJiaList = pingJiaList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.third_pingjia, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        PingJiaItem item = pingJiaList.get(position);
        holder.userNum.setText(item.getUserNum());
        holder.userOption.setText(item.getUserOption());
        holder.userGreat.setText(item.getUserGreat());
    }

    @Override
    public int getItemCount() {
        return pingJiaList.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        TextView userNum;
        TextView userOption;
        TextView userGreat;

        public ViewHolder(View itemView) {
            super(itemView);
            userNum = itemView.findViewById(R.id.user_num);
            userOption = itemView.findViewById(R.id.user_option);
            userGreat = itemView.findViewById(R.id.user_great);
        }
    }
}